#ifndef _ISO14443_H
#define _ISO14443_H

#include "stm32f0xx.h"
#include "rd522.h"
#include "delay.h"
#include "usart.h"
#include "string.h"
#include "des.h"

#define PICC_REQIDL           0x26               //寻天线区内未进入休眠状态
#define PICC_REQALL           0x52               //寻天线区内全部卡
#define PICC_ANTICOLL1        0x93               //防冲撞
#define PICC_ANTICOLL2        0x95               //防冲撞
#define PICC_ANTICOLL3        0x97               //防冲撞
#define PICC_HLTA             0x50               //休眠

//命令数据缓存结构体，用来保存发送的
//命令和数据，然后保存返回接收的数据
typedef struct
{
	uint8_t length;		//命令长度
	uint8_t buff[128];	//命令缓冲
}pcd_cmd_t;

int8_t pcd_request(uint8_t req_code, uint8_t *ptagtype);
int8_t pcd_hlta(void);
int8_t pcd_anticoll(uint8_t sel_code, uint8_t *uid);
int8_t pcd_select(uint8_t select_code, uint8_t *psnr, uint8_t *psak);
int8_t pcd_rats_a(uint8_t *ats);
int8_t pcd_set_pps(uint8_t rate);
int8_t pcd_deselect(void);
int8_t pcd_get_card_uid(uint8_t *cln, uint8_t *uid, uint8_t *sak_tmp);
int8_t pcd_cmd_transceive(pcd_cmd_t *pcd_cmd);

int8_t pcd_creat_key(uint8_t *key);
int8_t pcd_creat_df(uint8_t *file_id);
int8_t pcd_creat_bin(uint8_t *file_id);

#endif

